package com.zsh.rabbitmq.eight;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.zsh.rabbitmq.utils.RabbitMQUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zsh
 * @Description 死信队列实战，消费者2
 * @create 2022-05-06 10:11
 */
public class Consumer02 {
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();

        System.out.println("c2等待接收消息......");

        //接收消息
        DeliverCallback deliverCallback = (consumerTag, message) ->{
            String msg = new String(message.getBody(),"UTF-8");
            System.out.println("c2 接收到的消息是：" + msg);
        };

        channel.basicConsume(DEAD_QUEUE,true,deliverCallback,consumerTag ->{});
    }
}
